﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;
using XCode;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace BingZi.HY.Core
{
    /// <summary>商品评论</summary>
    [Serializable]
    [DataObject]
    [Description("商品评论")]
    [BindIndex("PK_app_Comment", true, "ID")]
    [BindTable("app_Comment", Description = "商品评论", ConnName = "Center")]
    public partial class app_Comment<TEntity> : Iapp_Comment
    {
        #region 属性
        private Int32 _ID = 0;
        /// <summary>评论编号</summary>
        [DisplayName("评论编号")]
        [Description("评论编号")]
        [DataObjectField(true, true, false, 10)]
        [BindColumn(1, "ID", "评论编号", null, "int", 10, 0, false)]
        public virtual Int32 ID
        {
            get { return _ID; }
            set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } }
        }

        private Int32 _ProductID = 0;
        /// <summary>商品编号</summary>
        [DisplayName("商品编号")]
        [Description("商品编号")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(2, "ProductID", "商品编号", null, "int", 10, 0, false)]
        public virtual Int32 ProductID
        {
            get { return _ProductID; }
            set { if (OnPropertyChanging("ProductID", value)) { _ProductID = value; OnPropertyChanged("ProductID"); } }
        }

        private Int32 _OrderID = 0;
        /// <summary>订单编号</summary>
        [DisplayName("订单编号")]
        [Description("订单编号")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(3, "OrderID", "订单编号", null, "int", 10, 0, false)]
        public virtual Int32 OrderID
        {
            get { return _OrderID; }
            set { if (OnPropertyChanging("OrderID", value)) { _OrderID = value; OnPropertyChanged("OrderID"); } }
        }

        private String _ContentText = String.Empty;
        /// <summary>评论内容</summary>
        [DisplayName("评论内容")]
        [Description("评论内容")]
        [DataObjectField(false, false, false, 512)]
        [BindColumn(4, "ContentText", "评论内容", null, "nvarchar(512)", 0, 0, true)]
        public virtual String ContentText
        {
            get { return _ContentText; }
            set { if (OnPropertyChanging("ContentText", value)) { _ContentText = value; OnPropertyChanged("ContentText"); } }
        }

        private Int32 _Score = 0;
        /// <summary>评分</summary>
        [DisplayName("评分")]
        [Description("评分")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(5, "Score", "评分", null, "tinyint", 3, 0, false)]
        public virtual Int32 Score
        {
            get { return _Score; }
            set { if (OnPropertyChanging("Score", value)) { _Score = value; OnPropertyChanged("Score"); } }
        }

        private DateTime _LastTime = DateTime.Now;
        /// <summary>最后更新时间</summary>
        [DisplayName("最后更新时间")]
        [Description("最后更新时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(6, "LastTime", "最后更新时间", null, "datetime", 3, 0, false)]
        public virtual DateTime LastTime
        {
            get { return _LastTime; }
            set { if (OnPropertyChanging("LastTime", value)) { _LastTime = value; OnPropertyChanged("LastTime"); } }
        }

        private Int32 _LastUser = 0;
        /// <summary>最后更新用户</summary>
        [DisplayName("最后更新用户")]
        [Description("最后更新用户")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(7, "LastUser", "最后更新用户", null, "int", 10, 0, false)]
        public virtual Int32 LastUser
        {
            get { return _LastUser; }
            set { if (OnPropertyChanging("LastUser", value)) { _LastUser = value; OnPropertyChanged("LastUser"); } }
        }

        private String _LastIP = String.Empty;
        /// <summary>最后更新IP</summary>
        [DisplayName("最后更新IP")]
        [Description("最后更新IP")]
        [DataObjectField(false, false, false, 50)]
        [BindColumn(8, "LastIP", "最后更新IP", null, "nvarchar(50)", 0, 0, true)]
        public virtual String LastIP
        {
            get { return _LastIP; }
            set { if (OnPropertyChanging("LastIP", value)) { _LastIP = value; OnPropertyChanged("LastIP"); } }
        }


        private Int32 _Status = (Int32)EnumCommentStatus.Unaudited;
        /// <summary>状态</summary>
        [DisplayName("状态")]
        [Description("状态")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(9, "Status", "状态", null, "tinyint", 3, 0, false)]
        public virtual Int32 Status
        {
            get { return _Status; }
            set { if (OnPropertyChanging("Status", value)) { _Status = value; OnPropertyChanged("Status"); } }
        }
		#endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// 一个索引，基类使用反射实现。
        /// 派生实体类可重写该索引，以避免反射带来的性能损耗
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        public override Object this[String name]
        {
            get
            {
                switch (name)
                {
                    case "ID" : return _ID;
                    case "ProductID" : return _ProductID;
                    case "OrderID" : return _OrderID;
                    case "ContentText" : return _ContentText;
                    case "Score" : return _Score;
                    case "LastTime" : return _LastTime;
                    case "LastUser" : return _LastUser;
                    case "LastIP" : return _LastIP;
                    case "Status": return _Status;
                    default: return base[name];
                }
            }
            set
            {
                switch (name)
                {
                    case "ID" : _ID = Convert.ToInt32(value); break;
                    case "ProductID" : _ProductID = Convert.ToInt32(value); break;
                    case "OrderID" : _OrderID = Convert.ToInt32(value); break;
                    case "ContentText" : _ContentText = Convert.ToString(value); break;
                    case "Score" : _Score = Convert.ToInt32(value); break;
                    case "LastTime" : _LastTime = Convert.ToDateTime(value); break;
                    case "LastUser" : _LastUser = Convert.ToInt32(value); break;
                    case "LastIP" : _LastIP = Convert.ToString(value); break;
                    case "Status": _Status = Convert.ToInt32(value); break;
                    default: base[name] = value; break;
                }
            }
        }
        #endregion

        #region 字段名
        /// <summary>取得商品评论字段信息的快捷方式</summary>
        public class _
        {
            ///<summary>评论编号</summary>
            public static readonly FieldItem ID = FindByName("ID");

            ///<summary>商品编号</summary>
            public static readonly FieldItem ProductID = FindByName("ProductID");

            ///<summary>订单编号</summary>
            public static readonly FieldItem OrderID = FindByName("OrderID");

            ///<summary>评论内容</summary>
            public static readonly FieldItem ContentText = FindByName("ContentText");

            ///<summary>评分</summary>
            public static readonly FieldItem Score = FindByName("Score");

            ///<summary>最后更新时间</summary>
            public static readonly FieldItem LastTime = FindByName("LastTime");

            ///<summary>最后更新用户</summary>
            public static readonly FieldItem LastUser = FindByName("LastUser");

            ///<summary>最后更新IP</summary>
            public static readonly FieldItem LastIP = FindByName("LastIP");

            ///<summary>状态</summary>
            public static readonly FieldItem Status = FindByName("Status");

            static FieldItem FindByName(String name) { return Meta.Table.FindByName(name); }
        }
        #endregion
    }

    /// <summary>商品评论接口</summary>
    public partial interface Iapp_Comment
    {
        #region 属性
        /// <summary>评论编号</summary>
        Int32 ID { get; set; }

        /// <summary>商品编号</summary>
        Int32 ProductID { get; set; }

        /// <summary>订单编号</summary>
        Int32 OrderID { get; set; }

        /// <summary>评论内容</summary>
        String ContentText { get; set; }

        /// <summary>评分</summary>
        Int32 Score { get; set; }

        /// <summary>最后更新时间</summary>
        DateTime LastTime { get; set; }

        /// <summary>最后更新用户</summary>
        Int32 LastUser { get; set; }

        /// <summary>最后更新IP</summary>
        String LastIP { get; set; }

        /// <summary>状态</summary>
        Int32 Status { get; set; }
        #endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        Object this[String name] { get; set; }
        #endregion
    }
}